import java.util.HashMap;
import java.util.Scanner;

/**
 * @author yu
 * @date 2025年04月17日 23:22
 */
public class _20250412_01 {
    public static int function(int n , int[] a){
        HashMap<Integer, Integer> map = new HashMap<>();
        int mostFreq = 0;//最大频率
        for (int num : a) {
            int count = map.getOrDefault(num,0);
            map.put(num, count+1);
            mostFreq = Math.max(count +1 ,mostFreq);
        }
        return n-mostFreq;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextInt();
        }
        System.out.println(function(n,a));
        scanner.close();

        /*
        try {
            // 读取数组长度
            int n = scanner.nextInt();
            int[] a = new int[n];
            // 读取数组元素
            for (int i = 0; i < n; i++) {
                a[i] = scanner.nextInt();
            }

            // 计算并输出最少操作次数
            int result = function(n, a);
            System.out.println(result);
        } catch (Exception e) {
            System.out.println("输入数据格式有误，请检查输入。");
        } finally {
            // 关闭Scanner资源
            scanner.close();
        }
        */
    }
}

